import {
	request,
	baseUrl
} from "../../request.js"

//域名 端口号
//var baseUrl = 'https://wzxlovemzy.com:6001/user'


/**
 * 1，支付
 */
export function userRechargeAmount(price, zfbTitle = '支付宝充值') {
	return request({
		url: baseUrl + '/payZfb/userRechargeAmount',
		method: 'POST',
		data: {
			price,
			userId: uni.getStorageSync('userId'),
			zfbTitle: zfbTitle || ''
		}
	})
}

/**
 * 2，用户购买闲置
 * @param {Object} price
 * @param {Object} orderId
 */
export function userRechargeOrder(price, orderId) {
	return request({
		url: baseUrl + '/payZfb/userRechargeOrder',
		method: 'POST',
		data: {
			price,
			userId: uni.getStorageSync('userId'),
			orderId
		}
	})
}

/**
 * 3，支付宝发布商品
 * @param {Object} req
 */
export function userReleaseByZfb(res) {
	return request({
		url: baseUrl + '/payZfb/userReleaseByZfb',
		method: 'POST',
		data: {
			address: res.address || '',
			detail: res.detail || '',
			gender: res.gender || '',
			imgs: res.imgs || '',
			price: res.price || 0,
			releaseUserId: uni.getStorageSync('userId'),
			state: '1',
			time: res.time || '',
			type: res.type,
			typeName: res.typeName,
			weight: res.weight || '',
			dynamicType: res.dynamicType || '',
			orderState: '1', //默认为未下单
			//releaseUserDataState: '1', //默认用户可查看
			orderDataState: '1' //默认下单者可查看
		}
	})
}

/**
 * 4，支付宝绑定接口
 * @param {Object} userId
 * @param {Object} authCode
 */
export function userBindingZfb(authCode) {
	return request({
		url: baseUrl + '/payZfb/userBindingZfb',
		method: 'POST',
		data: {
			userId: uni.getStorageSync('userId'),
			authCode
		}
	})
}